package Collection.work;

import java.security.spec.RSAOtherPrimeInfo;
import java.util.ArrayList;
import java.util.List;

public class subListDemo {
    public static void main(String[] args) {
        List<Integer> list =new ArrayList<>();
        for (int i=0;i<10;i++){
            list.add(i*10);

        }
        System.out.println(list);

        List<Integer> sublist =list.subList(3,8);//截取之后得到一个子集
        System.out.println(sublist);

        for (int i=0;i<sublist.size();i++){
            sublist.set(i,sublist.get(i)*10);
        }
        System.out.println("sublist:"+sublist);//对子集操作对应原集随之变化
        System.out.println("list"+list);

        list.set(3,1000);
        System.out.println("list"+list);//原集合数据改变子集随之改变
        System.out.println("sublist:"+sublist);

        list.remove(9);
        System.out.println("list"+list);//原集合修改长度  子集不能做任何操作， 操作异常  需要重新获取子集
//        System.out.println("sublist:"+sublist);
        sublist =list.subList(3,8);
        System.out.println("sublist:"+sublist);
    }






}
